package com.zw.yzk.kabu.data.repository;


import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.AtUserEntity;
import com.zw.yzk.kabu.data.network.entity.SearchUserEntity;
import com.zw.yzk.kabu.data.network.service.AtUserService;
import com.zw.yzk.kabu.data.network.service.SearchUserService;
import com.zw.yzk.kabu.data.network.task.AthUserTask;
import com.zw.yzk.kabu.data.network.task.SearchUserTask;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2017/1/4.
 */

public class SearchUserRepository extends CommonRepository {

    @Inject
    public SearchUserRepository() {
    }

    @Override
    protected Observable connectServer(Task task) {
        SearchUserService service = ServiceGenerator.createService(SearchUserService.class);
        SearchUserTask uTask = (SearchUserTask) task;
        return service.searchUser(uTask.userId, uTask.accessToken, uTask.start, 10, uTask.key);
    }

    @Override
    protected Func1<SearchUserEntity, Observable> getServerData() {
        return new Func1<SearchUserEntity, Observable>() {
            @Override
            public Observable call(SearchUserEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
